/**
 * Copyright &copy; 2016-2017 <a href="http://git.oschina.net/whoamien/backend_management">Backend Management</a> All rights reserved.
 */
package com.xw.app.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Maps;
import com.xw.app.dao.SystemConfigDAO;
import com.xw.app.model.SystemConfig;
import com.xw.app.service.SystemConfigService;
import com.xw.framework.base.service.BaseServiceImpl;

/**
 * The Class SystemConfigServiceImpl.
 *
 * @author Xi Wei
 */
@Service
@Transactional
public class SystemConfigServiceImpl extends BaseServiceImpl<SystemConfig, Long> implements SystemConfigService
{

	@Autowired
	private SystemConfigDAO systemConfigDAO;
	
	/* (non-Javadoc)
	 * @see com.xw.app.service.SystemConfigService#getActiveSystemConfig()
	 */
	@Override
	public SystemConfig getActiveSystemConfig() {
		return systemConfigDAO.findByActiveTrue();
	}

	/* (non-Javadoc)
	 * @see com.xw.app.service.SystemConfigService#getSystemMap()
	 */
	@Override
	public Map<Long,SystemConfig> getSystemMap(){
		Map<Long,SystemConfig> map = Maps.newHashMap();
		Iterable<SystemConfig> systemList = systemConfigDAO.findAll();
		systemList.forEach(x -> map.put(x.getId(), x));
		return map;
		
	}
}
